package fulbiNet.dao;


	import java.sql.Connection;
import java.sql.Date;
	import java.sql.PreparedStatement;
	import java.sql.ResultSet;
	import java.sql.SQLException;
	import java.util.ArrayList;
	import java.util.Collection;

	import fulbiNet.execpcion.DAOExcepcion;
import fulbiNet.modelo.Alquiler;
import fulbiNet.modelo.Cancha;
import fulbiNet.modelo.Horario;
	import fulbiNet.modelo.Local;
import fulbiNet.util.ConexionBD;

	public class HorarioDAO extends BaseDAO {

		public void insertar(Horario vo) throws DAOExcepcion {
			System.out.println("LocalDAO: insertar(Horario vo)");
			String query = "INSERT INTO Horario(idCancha, turno, desdehora, hastahora, tarifa, dia)  VALUES (?,?,?,?,?,?)";
			Connection con = null;
			PreparedStatement stmt = null;
			try {
				con = ConexionBD.obtenerConexion();
				stmt = con.prepareStatement(query);
				
				stmt.setInt(1, vo.getoCancha().getCodigo());
				stmt.setString(2, vo.getTurno());
				stmt.setDate(3, vo.getDesdehora());
				stmt.setDate(4, vo.getHastahora());
				stmt.setFloat(5,vo.getTarifa());
				stmt.setString(6,vo.getDia2());
						
				int i = stmt.executeUpdate();
				if (i != 1) {
					throw new SQLException("No se pudo insertar");
				}
			} catch (SQLException e) {
				System.err.println(e.getMessage());
				throw new DAOExcepcion(e.getMessage());
			} finally {
				this.cerrarStatement(stmt);
				this.cerrarConexion(con);
			}
		}
		

		
	}
